package org.shan.lf.sever.controller;

import com.mlnx.common.entity.Response;
import com.mlnx.common.utils.MyLog;
import org.shan.lf.common.exception.LfServiceException;
import org.springframework.http.HttpStatus;
import org.springframework.web.bind.annotation.ControllerAdvice;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.ResponseStatus;

/**
 * Created by amanda.shan on 2019/7/1.
 */
@ControllerAdvice
@ResponseBody
public class WebExceptionHandle {

    private static MyLog logger = MyLog.getLog(WebExceptionHandle.class);

    @ResponseStatus(HttpStatus.OK)
    @ExceptionHandler(LfServiceException.class)
    public Response handleHttpUserException(LfServiceException e) {

        logger.error(e, "请求处理错误信息");

        return new Response(e.getCode(), e.getDescribe());
    }


}
